
import { createApp } from 'vue' // 这里直接导入'vue'而不是地址，是因为已经将vue下载到node_module目录下了
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-persistedstate-plugin'
const pinia = createPinia()
const persist = createPersistedState();
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'

const app = createApp(App)
// element plus icon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

pinia.use(persist)
app.use(pinia)
app.use(router)
app.use(ElementPlus)

app.mount('#app')
